#ifndef GEOMETRYENGINE_H
#define GEOMETRYENGINE_H

#include "api\grc_igeometryengine.hpp"
#include "game_controller\ih\game_controller_iscene.hpp"

#include <QGLFunctions>
#include <QGLShaderProgram>
#include <QMatrix4x4>
#include <QQuaternion>
#include <QVector2D>
#include <QBasicTimer>
#include <QGraphicsScene>

namespace GameController
{
	class GameControllerPlugin;
}
namespace GraphicConnector
{
	class GraphicConnectorPlugin;
}

namespace GraphicConnector {

class GeometryEngine
	:	protected QGLFunctions
	,	public IGeometryEngine
{
public:

	struct VertexData
	{
		QVector3D position;
		QVector2D texCoord;
	};

public:

	GeometryEngine(	QWidget *parent = nullptr );
	~GeometryEngine();
	virtual void setScene( GameController::IScene::Ptr _scene );


protected:
	virtual void paintGL();
	void resizeGL(int w, int h);

	void initTexture( GameModel::IObject::Ptr _object );
	void initShaders();

private:
	GameController::IScene::Ptr m_scene;

	GLuint vboIds[2];
	std::vector< GLuint > m_textures;

	QGLShaderProgram m_program;
	GraphicConnector::GraphicConnectorPlugin* m_graphics;

	QMatrix4x4 projection;
	QGraphicsScene m_graphicScene;
};

} // namespace GraphicConnector

#endif // GEOMETRYENGINE_H
